table of contents
SAR(1) | Linux User's Manual | SAR(1) |
NAME¶
sar - Collect, report, or save system activity information.
SYNOPSIS¶
sar [ -A ] [ -B ] [ -b ] [ -C ] [ -D ] [ -d ] [ -F [ MOUNT ] ] [ -H ] [ -h ] [ -p ] [ -q ] [ -r [ ALL ] ] [ -S ] [ -t ] [ -u [ ALL ] ] [ -V ] [ -v ] [ -W ] [ -w ] [ -y ] [ -z ] [ --help ] [ --human ] [ --sadc ] [ -I { int_list | SUM | ALL } ] [ -P { cpu_list | ALL } ] [ -m { keyword [,...] | ALL } ] [ -n { keyword [,...] | ALL } ] [ -j { ID | LABEL | PATH | UUID | ... } ] [ -f [ filename ] | -o [ filename ] | -[0-9]+ ] [ -i interval ] [ -s [ hh:mm[:ss] ] ] [ -e [ hh:mm[:ss] ] ] [ interval [ count ] ]
DESCRIPTION¶
The sar command writes to standard output the contents of selected cumulative activity counters in the operating system. The accounting system, based on the values in the count and interval parameters, writes information the specified number of times spaced at the specified intervals in seconds. If the interval parameter is set to zero, the sar command displays the average statistics for the time since the system was started. If the interval parameter is specified without the count parameter, then reports are generated continuously. The collected data can also be saved in the file specified by the -o filename flag, in addition to being displayed onto the screen. If filename is omitted, sar uses the standard system activity daily data file (see below). By default all the data available from the kernel are saved in the data file.
The sar command extracts and writes to standard output records previously saved in a file. This file can be either the one specified by the -f flag or, by default, the standard system activity daily data file. It is also possible to enter -1, -2 etc. as an argument to sar to display data of that days ago. For example, -1 will point at the standard system activity file of yesterday.
Standard system activity daily data files are named saDD or saYYYYMMDD, where YYYY stands for the current year, MM for the current month and DD for the current day. They are the default files used by sar only when no filename has been explicitly specified. When used to write data to files (with its option -o), sar will use saYYYYMMDD if option -D has also been specified, else it will use saDD. When used to display the records previously saved in a file, sar will look for the most recent of saDD and saYYYYMMDD, and use it.
Standard system activity daily data files are located in the /var/log/sa directory by default. Yet it is possible to specify an alternate location for them: If a directory (instead of a plain file) is used with options -f or -o then it will be considered as the directory containing the data files.
Without the -P flag, the sar command reports system-wide (global among all processors) statistics, which are calculated as averages for values expressed as percentages, and as sums otherwise. If the -P flag is given, the sar command reports activity which relates to the specified processor or processors. If -P ALL is given, the sar command reports statistics for each individual processor and global statistics among all processors. Offline processors are not displayed.
You can select information about specific system activities using flags. Not specifying any flags selects only CPU activity. Specifying the -A flag selects all possible activities.
The default version of the sar command (CPU utilization report) might be one of the first facilities the user runs to begin system activity investigation, because it monitors major system resources. If CPU utilization is near 100 percent (user + nice + system), the workload sampled is CPU-bound.
If multiple samples and multiple reports are desired, it is convenient to specify an output file for the sar command. Run the sar command as a background process. The syntax for this is:
sar -o datafile interval count >/dev/null 2>&1 &
All data are captured in binary form and saved to a file (datafile). The data can then be selectively displayed with the sar command using the -f option. Set the interval and count parameters to select count records at interval second intervals. If the count parameter is not set, all the records saved in the file will be selected. Collection of data in this manner is useful to characterize system usage over a period of time and determine peak usage hours.
Note: The sar command only reports on local activities.
OPTIONS¶
- -A
- This is equivalent to specifying -bBdFHqSuvwWy -I SUM -I ALL -m ALL -n ALL -r ALL -u ALL -P ALL.
- -B
- Report paging statistics. The following values are displayed:
pgpgin/s
pgpgout/s
fault/s
majflt/s
pgfree/s
pgscank/s
pgscand/s
pgsteal/s
%vmeff
- -b
- Report I/O and transfer rate statistics. The following values are
displayed:
tps
rtps
wtps
bread/s
bwrtn/s
- -C
- When reading data from a file, tell sar to display comments that have been inserted by sadc.
- -D
- Use saYYYYMMDD instead of saDD as the standard system activity daily data file name. This option works only when used in conjunction with option -o to save data to file.
- -d
- Report activity for each block device. When data are displayed, the device
specification devM-n is generally used (DEV column). M is the major
number of the device and n its minor number. Device names may also be
pretty-printed if option -p is used or persistent device names can be
printed if option -j is used (see below). Note that disk activity depends
on sadc options -S DISK and -S XDISK to be collected.
The following values are displayed:
tps
rkB/s
wkB/s
areq-sz
Note: In previous versions, this field was known as avgrq-sz and was expressed in sectors.
aqu-sz
Note: In previous versions, this field was known as avgqu-sz.
await
svctm
%util
- -e [ hh:mm[:ss] ]
- Set the ending time of the report. The default ending time is 18:00:00. Hours must be given in 24-hour format. This option can be used when data are read from or written to a file (options -f or -o).
- -F [ MOUNT ]
- Display statistics for currently mounted filesystems. Pseudo-filesystems
are ignored. At the end of the report, sar will display a summary
of all those filesystems. Use of the MOUNT parameter keyword
indicates that mountpoint will be reported instead of filesystem device.
Note that filesystems statistics depend on sadc option -S
XDISK to be collected.
The following values are displayed:
MBfsfree
MBfsused
%fsused
%ufsused
Ifree
Iused
%Iused
- -f [ filename ]
- Extract records from filename (created by the -o filename flag). The default value of the filename parameter is the current standard system activity daily data file. If filename is a directory instead of a plain file then it is considered as the directory where the standard system activity daily data files are located. The -f option is exclusive of the -o option.
- -H
- Report hugepages utilization statistics. The following values are
displayed:
kbhugfree
kbhugused
%hugused
- -h
- Make the output of sar easier to read by a human. Options --human and -p (pretty-print) are enabled implicitly with this option.
- --help
- Display a short help message then exit.
- --human
- Print sizes in human readable format (e.g. 1.0k, 1.2M, etc.) The units displayed with this option supersede any other default units (e.g. kilobytes, sectors...) associated with the metrics.
- -I { int_list | SUM | ALL }
- Report statistics for interrupts. int_list is a list of comma-separated values or range of values (e.g., 0-16,35,400-). The SUM keyword indicates that the total number of interrupts received per second is to be displayed. The ALL keyword indicates that statistics from all interrupts, including potential APIC interrupt sources, are to be reported. Note that interrupt statistics depend on sadc option "-S INT" to be collected.
- -i interval
- Select data records at seconds as close as possible to the number specified by the interval parameter.
- -j { ID | LABEL | PATH | UUID | ... }
- Display persistent device names. Use this option in conjunction with option -d. Options ID, LABEL, etc. specify the type of the persistent name. These options are not limited, only prerequisite is that directory with required persistent names is present in /dev/disk. If persistent name is not found for the device, the device name is pretty-printed (see option -p below).
- -m { keyword [,...] | ALL }
- Report power management statistics. Note that these statistics depend on
sadc's option "-S POWER" to be collected.
Possible keywords are CPU, FAN, FREQ, IN, TEMP and USB.
With the CPU keyword, statistics about CPU are reported. The following value is displayed:
MHz
With the FAN keyword, statistics about fans speed are reported. The following values are displayed:
rpm
drpm
DEVICE
With the FREQ keyword, statistics about CPU clock frequency are reported. The following value is displayed:
wghMHz
With the IN keyword, statistics about voltage inputs are reported. The following values are displayed:
inV
%in
DEVICE
With the TEMP keyword, statistics about devices temperature are reported. The following values are displayed:
degC
%temp
DEVICE
With the USB keyword, the sar command takes a snapshot of all the USB devices currently plugged into the system. At the end of the report, sar will display a summary of all those USB devices. The following values are displayed:
BUS
idvendor
idprod
maxpower
manufact
product
The ALL keyword is equivalent to specifying all the keywords above and therefore all the power management statistics are reported.
- -n { keyword [,...] | ALL }
- Report network statistics.
Possible keywords are DEV, EDEV, FC, ICMP, EICMP, ICMP6, EICMP6, IP, EIP, IP6, EIP6, NFS, NFSD, SOCK, SOCK6, SOFT, TCP, ETCP, UDP and UDP6.
With the DEV keyword, statistics from the network devices are reported. The following values are displayed:
IFACE
rxpck/s
txpck/s
rxkB/s
txkB/s
rxcmp/s
txcmp/s
rxmcst/s
%ifutil
With the EDEV keyword, statistics on failures (errors) from the network devices are reported. The following values are displayed:
IFACE
rxerr/s
txerr/s
coll/s
rxdrop/s
txdrop/s
txcarr/s
rxfram/s
rxfifo/s
txfifo/s
With the FC keyword, statistics about fibre channel traffic are reported. Note that fibre channel statistics depend on sadc's option "-S DISK" to be collected. The following values are displayed:
FCHOST
fch_rxf/s
fch_txf/s
fch_rxw/s
fch_txw/s
With the ICMP keyword, statistics about ICMPv4 network traffic are reported. Note that ICMPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
imsg/s
omsg/s
iech/s
iechr/s
oech/s
oechr/s
itm/s
itmr/s
otm/s
otmr/s
iadrmk/s
iadrmkr/s
oadrmk/s
oadrmkr/s
With the EICMP keyword, statistics about ICMPv4 error messages are reported. Note that ICMPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
ierr/s
oerr/s
idstunr/s
odstunr/s
itmex/s
otmex/s
iparmpb/s
oparmpb/s
isrcq/s
osrcq/s
iredir/s
oredir/s
With the ICMP6 keyword, statistics about ICMPv6 network traffic are reported. Note that ICMPv6 statistics depend on sadc's option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
imsg6/s
omsg6/s
iech6/s
iechr6/s
oechr6/s
igmbq6/s
igmbr6/s
ogmbr6/s
igmbrd6/s
ogmbrd6/s
irtsol6/s
ortsol6/s
irtad6/s
inbsol6/s
onbsol6/s
inbad6/s
onbad6/s
With the EICMP6 keyword, statistics about ICMPv6 error messages are reported. Note that ICMPv6 statistics depend on sadc's option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
ierr6/s
idtunr6/s
odtunr6/s
itmex6/s
otmex6/s
iprmpb6/s
oprmpb6/s
iredir6/s
oredir6/s
ipck2b6/s
opck2b6/s
With the IP keyword, statistics about IPv4 network traffic are reported. Note that IPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
irec/s
fwddgm/s
idel/s
orq/s
asmrq/s
asmok/s
fragok/s
fragcrt/s
With the EIP keyword, statistics about IPv4 network errors are reported. Note that IPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
ihdrerr/s
iadrerr/s
iukwnpr/s
idisc/s
odisc/s
onort/s
asmf/s
fragf/s
With the IP6 keyword, statistics about IPv6 network traffic are reported. Note that IPv6 statistics depend on sadc's option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
irec6/s
fwddgm6/s
idel6/s
orq6/s
asmrq6/s
asmok6/s
imcpck6/s
omcpck6/s
fragok6/s
fragcr6/s
With the EIP6 keyword, statistics about IPv6 network errors are reported. Note that IPv6 statistics depend on sadc's option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
ihdrer6/s
iadrer6/s
iukwnp6/s
i2big6/s
idisc6/s
odisc6/s
inort6/s
onort6/s
asmf6/s
fragf6/s
itrpck6/s
With the NFS keyword, statistics about NFS client activity are reported. The following values are displayed:
call/s
retrans/s
read/s
write/s
access/s
getatt/s
With the NFSD keyword, statistics about NFS server activity are reported. The following values are displayed:
scall/s
badcall/s
packet/s
udp/s
tcp/s
hit/s
miss/s
sread/s
swrite/s
saccess/s
sgetatt/s
With the SOCK keyword, statistics on sockets in use are reported (IPv4). The following values are displayed:
totsck
tcpsck
udpsck
rawsck
ip-frag
tcp-tw
With the SOCK6 keyword, statistics on sockets in use are reported (IPv6). Note that IPv6 statistics depend on sadc's option "-S IPV6" to be collected. The following values are displayed:
tcp6sck
udp6sck
raw6sck
ip6-frag
With the SOFT keyword, statistics about software-based network processing are reported. The following values are displayed:
total/s
dropd/s
squeezd/s
rx_rps/s
flw_lim/s
With the TCP keyword, statistics about TCPv4 network traffic are reported. Note that TCPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
active/s
passive/s
iseg/s
oseg/s
With the ETCP keyword, statistics about TCPv4 network errors are reported. Note that TCPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
atmptf/s
estres/s
retrans/s
isegerr/s
orsts/s
With the UDP keyword, statistics about UDPv4 network traffic are reported. Note that UDPv4 statistics depend on sadc's option "-S SNMP" to be collected. The following values are displayed (formal SNMP names between square brackets):
idgm/s
odgm/s
noport/s
idgmerr/s
With the UDP6 keyword, statistics about UDPv6 network traffic are reported. Note that UDPv6 statistics depend on sadc's option "-S IPV6" to be collected. The following values are displayed (formal SNMP names between square brackets):
idgm6/s
odgm6/s
noport6/s
idgmer6/s
The ALL keyword is equivalent to specifying all the keywords above and therefore all the network activities are reported.
- -o [ filename ]
- Save the readings in the file in binary form. Each reading is in a separate record. The default value of the filename parameter is the current standard system activity daily data file. If filename is a directory instead of a plain file then it is considered as the directory where the standard system activity daily data files are located. The -o option is exclusive of the -f option. All the data available from the kernel are saved in the file (in fact, sar calls its data collector sadc with the option "-S ALL". See sadc(8) manual page).
- -P { cpu_list | ALL }
- Report per-processor statistics for the specified processor or processors. cpu_list is a list of comma-separated values or range of values (e.g., 0,2,4-7,12-). Note that processor 0 is the first processor, and processor all is the global average among all processors. Specifying the ALL keyword reports statistics for each individual processor, and globally for all processors. Offline processors are not displayed.
- -p
- Pretty-print device names. Use this option in conjunction with option -d. By default names are printed as devM-n where M and n are the major and minor numbers for the device. Use of this option displays the names of the devices as they (should) appear in /dev. Name mappings are controlled by /etc/sysconfig/sysstat.ioconf.
- -q
- Report queue length and load averages. The following values are displayed:
runq-sz
plist-sz
ldavg-1
ldavg-5
ldavg-15
blocked
- -r [ ALL ]
- Report memory utilization statistics. The ALL keyword indicates
that all the memory fields should be displayed. The following values may
be displayed:
kbmemfree
kbavail
kbmemused
%memused
kbbuffers
kbcached
kbcommit
%commit
kbactive
kbinact
kbdirty
kbanonpg
kbslab
kbkstack
kbpgtbl
kbvmused
- -S
- Report swap space utilization statistics. The following values are
displayed:
kbswpfree
kbswpused
%swpused
kbswpcad
%swpcad
- -s [ hh:mm[:ss] ]
- Set the starting time of the data, causing the sar command to extract records time-tagged at, or following, the time specified. The default starting time is 08:00:00. Hours must be given in 24-hour format. This option can be used only when data are read from a file (option -f).
- --sadc
- Indicate which data collector is called by sar. If the data collector is sought in PATH then enter "which sadc" to know where it is located.
- -t
- When reading data from a daily data file, indicate that sar should display the timestamps in the original local time of the data file creator. Without this option, the sar command displays the timestamps in the user's locale time.
- -u [ ALL ]
- Report CPU utilization. The ALL keyword indicates that all the CPU
fields should be displayed. The report may show the following fields:
%user
%usr
%nice
%system
%sys
%iowait
%steal
%irq
%soft
%guest
%gnice
%idle
- -V
- Print version number then exit.
- -v
- Report status of inode, file and other kernel tables. The following values
are displayed:
dentunusd
file-nr
inode-nr
pty-nr
- -W
- Report swapping statistics. The following values are displayed:
pswpin/s
pswpout/s
- -w
- Report task creation and system switching activity.
proc/s
cswch/s
- -y
- Report TTY devices activity. The following values are displayed:
rcvin/s
xmtin/s
framerr/s
prtyerr/s
brk/s
ovrun/s
- -z
- Tell sar to omit output for any devices for which there was no activity during the sample period.
ENVIRONMENT¶
The sar command takes into account the following environment variables:
- S_COLORS
- When this variable is set, display statistics in color on the terminal.
Possible values for this variable are never, always or
auto (the latter is the default).
Please note that the color (being red, yellow, or some other color) used to display a value is not indicative of any kind of issue simply because of the color. It only indicates different ranges of values.
- S_COLORS_SGR
- Specify the colors and other attributes used to display statistics on the terminal. Its value is a colon-separated list of capabilities that defaults to C=33;22:H=31;1:I=32;22:M=35;1:N=34;1:R=31;22:Z=34;22. Supported capabilities are:
- C=
- SGR (Select Graphic Rendition) substring for comments inserted in the binary daily data files.
- H=
- SGR substring for percentage values greater than or equal to 75%.
- I=
- SGR substring for item names or values (eg. network interfaces, CPU number...)
- M=
- SGR substring for percentage values in the range from 50% to 75%.
- N=
- SGR substring for non-zero statistics values.
- R=
- SGR substring for restart messages.
- Z=
- SGR substring for zero values.
- S_TIME_DEF_TIME
- If this variable exists and its value is UTC then sar will save its data in UTC time (data will still be displayed in local time). sar will also use UTC time instead of local time to determine the current daily data file located in the /var/log/sa directory. This variable may be useful for servers with users located across several timezones.
- S_TIME_FORMAT
- If this variable exists and its value is ISO then the current locale will be ignored when printing the date in the report header. The sar command will use the ISO 8601 format (YYYY-MM-DD) instead. The timestamp will also be compliant with ISO 8601 format.
EXAMPLES¶
sar -u 2 5
sar -I 14 -o int14.file 2 10
sar -r -n DEV -f /var/log/sa/sa16
sar -A
BUGS¶
/proc filesystem must be mounted for the sar command to work.
All the statistics are not necessarily available, depending on the kernel version used. sar assumes that you are using at least a 2.6 kernel.
FILES¶
/var/log/sa/saDD
/var/log/sa/saYYYYMMDD
AUTHOR¶
Sebastien Godard (sysstat <at> orange.fr)
SEE ALSO¶
sadc(8), sa1(8), sa2(8), sadf(1), sysstat(5), pidstat(1), mpstat(1), iostat(1), vmstat(8)
FEBRUARY 2018 | Linux |